// index.js
// 获取应用实例
const app = getApp();
var page = 1;
Page({
  data: {
    tabs: [{
      name: "导游"
    }, {
      name: "领队"
    }, {
      name: "讲解员"
    }],
    tabs_daoyou: [{
      name: "国内"
    }, {
      name: "出境"
    }, {
      name: "景点"
    }],
    tabs_two: [{
      name: "推荐"
    }, {
      name: "最新"
    }, {
      name: "收藏"
    }],
    li:[1,2,3,4],
    currentTab:0,
    currentTab_two:0,
    hasUserInfo: true,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    flag:2, //1. 导游身份 2.旅行社游客身份
    shouquan:true
  },
  // 事件处理函数
  bindGetUserInfo: function (e) {    //授权操作
    if (e.detail.userInfo) {
      //用户按了允许授权按钮
      var that = this;
      console.log("用户的信息如下：");
      console.log(e.detail.userInfo);
      //授权成功后,通过改变让实现页面显示出来，
      that.setData({
          hasUserInfo:true
      })
      wx.reLaunch({
        url: '../phone/phone'
      })
    } else {
      //用户按了拒绝按钮
      wx.showModal({
        title: '警告',
        content: '您点击了拒绝授权，将无法进入小程序，请授权之后再进入!!!',
        showCancel: false,
        confirmText: '返回授权',
        success: function(res) {
          // 用户没有授权成功，不需要改变 isHide 的值
          if (res.confirm) {
            console.log('用户点击了“返回授权”');
          }
        }
      });
    }
  },
  bindDetail(e){
    // var trip_order_id = e.currentTarget.dataset.trip_order_id;
    // wx.navigateTo({
    //   url: '../tuikuan_zhong/tuikuan_zhong?trip_order_id='+trip_order_id,
    // })
    wx.navigateTo({
      url: '/page/index/pages/pisition_detail/pisition_detail'
    })
  },
  bindDetail_guide(){
    wx.navigateTo({
      url: '/page/index/pages/guide_detail/guide_detail'
    })
  },
  bindTab: function (e) {
    var that = this;
    // var index = e.currentTarget.dataset.index;
    // if(index==0){
    //   that.setData({
    //     days: 1
    //   })
    // }else if(index==1){
    //   that.setData({
    //     days: 2
    //   })
    // }else{
    //   that.setData({
    //     days: 3
    //   })
    // }
    that.setData({
      currentTab: e.currentTarget.dataset.index,
      orderList: [],
    })
    // page = 1;
    // this.getViewData()
  },
  
  bindTab_two: function (e) {
    var that = this;
    that.setData({
      currentTab_two: e.currentTarget.dataset.index,
      orderList: [],
    })
  },
  city(){
    wx.navigateTo({
      url: '/page/index/pages/city/city',
    })
  },
  shuaixuan(){
    wx.navigateTo({
      url: '/page/index/pages/shuaixuan/shuaixuan',
    })
  },
  fabu(){
    wx.navigateTo({
      url: '/page/index/pages/fabu/fabu',
    })
  },
  onLoad() {
    //判断是否授权过
    var that = this;
    //查看是否授权
    wx.getSetting({
      success: function(res) {
        if (res.authSetting['scope.userInfo']) {
          console.log("用户授权了");
          that.setData({
            hasUserInfo:true
          })
        } else {
          //用户没有授权
          console.log("用户没有授权");
          that.setData({
            hasUserInfo:false
          })
        }
      }
    });
  },
  getUserInfo(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    page=1;
    // this.setData({
    //   orderList:[]
    // })
    // this.getList()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    // page++
    // this.getList()
  },
})
